package com.qf.dao.impl;

import com.qf.dao.adminLoginDao;
import com.qf.domain.User;
import com.qf.utils.DataSourceUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

public class adminLoginDaoImpl implements adminLoginDao {
    private QueryRunner queryRunner= new QueryRunner(DataSourceUtil.getDataSource());
    @Override
    public User select(String password, String username) {
        String sql = " select * from db_shopping.tb_user where username=?and password=? ";
        try {
            return queryRunner.query(sql,new BeanHandler<>(User.class),username,password);
        } catch (SQLException throwables) {
            throw  new RuntimeException(throwables);
        }
    }
}
